package com.framework.modules.sys.controller;

import com.framework.entity.sys.SysAgent;
import com.framework.exception.util.RespResult;
import com.framework.service.AgentService;
import com.framework.service.TreeAgentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 合伙人关系表相关
 */
@RestController
@RequestMapping("/sys/systreeagent")
public class SysTreeAgentController extends AbstractController {

    @Autowired
    private TreeAgentService treeAgentService;
    @Autowired
    private AgentService agentService;

    /**
     * 导入树形关系
     * @return
     */
    @RequestMapping("/insertTree")
    public RespResult insertTree(){
        Long deptId = getUser().getDeptId();
        List<SysAgent> list = agentService.queryNormalAgentList(deptId);
        for (SysAgent sysAgent: list) {
            treeAgentService.insertTreeAgent(sysAgent.getAgentId());
        }
        return RespResult.ok();
    }
}
